home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS02.ADF / Emacs / ed.h < prev    next >
C/C++ Source or Header  |  1989-05-30  |  11KB  |  191 lines

  1. /* ed.h */
  2.  
  3. /*
  4.  * This file is the general header file for all parts of the MicroEMACS
  5.  * display editor. It contains definitions used by everyone, and it contains
  6.  * the stuff you have to edit to create a version of the editor for a specific
  7.  * operating system and terminal.
  8.  */
  9.  
  10. #define AMIGA   1                       /* AmigaDOS, Lattice            */
  11. #define ST520   0                       /* ST520, TOS                   */
  12. #define MWC86   0
  13. #define V7      0                       /* V7 UN*X or Coherent          */
  14. #define VMS     0                       /* VAX/VMS                      */
  15. #define CPM     0                       /* CP/M-86                      */
  16.  
  17. #ifndef MSDOS                           /* Already defined for Lattice  */
  18. #define MSDOS   0                       /* MS-DOS                       */
  19. #endif
  20.  
  21. #define ANSI    1
  22. #define VT52    0                       /* VT52 terminal (Zenith).      */
  23. #define VT100   0                       /* Handle VT100 style keypad.   */
  24. #define LK201   0                       /* Handle LK201 style keypad.   */
  25. #define RAINBOW 0                       /* Use Rainbow fast video.      */
  26. #define TERMCAP 0                       /* Use TERMCAP                  */
  27.  
  28. #define CVMVAS  1                       /* C-V, M-V arg. in screens.    */
  29.  
  30. #define NFILEN  80                      /* # of bytes, file name        */
  31. #define NBUFN   16                      /* # of bytes, buffer name      */
  32. #define NLINE   256                     /* # of bytes, line             */
  33. #define NKBDM   256                     /* # of strokes, keyboard macro */
  34. #define NPAT    80                      /* # of bytes, pattern          */
  35. #define HUGE    1000                    /* Huge number                  */
  36.  
  37. #define AGRAVE  0x60                    /* M- prefix,   Grave (LK201)   */
  38. #define METACH  0x1B                    /* M- prefix,   Control-[, ESC  */
  39. #define CTMECH  0x1C                    /* C-M- prefix, Control-\       */
  40. #define EXITCH  0x1D                    /* Exit level,  Control-]       */
  41. #define CTRLCH  0x1E                    /* C- prefix,   Control-^       */
  42. #define HELPCH  0x1F                    /* Help key,    Control-_       */
  43.  
  44. #define CTRL    0x0100                  /* Control flag, or'ed in       */
  45. #define META    0x0200                  /* Meta flag, or'ed in          */
  46. #define CTLX    0x0400                  /* ^X flag, or'ed in            */
  47.  
  48. #define FALSE   0                       /* False, no, bad, etc.         */
  49. #define TRUE    1                       /* True, yes, good, etc.        */
  50. #define ABORT   2                       /* Death, ^G, abort, etc.       */
  51.  
  52. #define FIOSUC  0                       /* File I/O, success.           */
  53. #define FIOFNF  1                       /* File I/O, file not found.    */
  54. #define FIOEOF  2                       /* File I/O, end of file.       */
  55. #define FIOERR  3                       /* File I/O, error.             */
  56.  
  57. #define CFCPCN  0x0001                  /* Last command was C-P, C-N    */
  58. #define CFKILL  0x0002                  /* Last command was a kill      */
  59.  
  60. /*
  61.  * There is a window structure allocated for every active display window. The
  62.  * windows are kept in a big list, in top to bottom screen order, with the
  63.  * listhead at "wheadp". Each window contains its own values of dot and mark.
  64.  * The flag field contains some bits that are set by commands to guide
  65.  * redisplay; although this is a bit of a compromise in terms of decoupling,
  66.  * the full blown redisplay is just too expensive to run for every input
  67.  * character. 
  68.  */
  69. typedef struct  WINDOW {
  70.         struct  WINDOW *w_wndp;         /* Next window                  */
  71.         struct  BUFFER *w_bufp;         /* Buffer displayed in window   */
  72.         struct  LINE *w_linep;          /* Top line in the window       */
  73.         struct  LINE *w_dotp;           /* Line containing "."          */
  74.         short   w_doto;                 /* Byte offset for "."          */
  75.         struct  LINE *w_markp;          /* Line containing "mark"       */
  76.         short   w_marko;                /* Byte offset for "mark"       */
  77.         char    w_toprow;               /* Origin 0 top row of window   */
  78.         char    w_ntrows;               /* # of rows of text in window  */
  79.         char    w_force;                /* If NZ, forcing row.          */
  80.         char    w_flag;                 /* Flags.                       */
  81. }       WINDOW;
  82.  
  83. #define WFFORCE 0x01                    /* Window needs forced reframe  */
  84. #define WFMOVE  0x02                    /* Movement from line to line   */
  85. #define WFEDIT  0x04                    /* Editing within a line        */
  86. #define WFHARD  0x08                    /* Better to a full display     */
  87. #define WFMODE  0x10                    /* Update mode line.            */
  88.  
  89. /*
  90.  * Text is kept in buffers. A buffer header, described below, exists for every
  91.  * buffer in the system. The buffers are kept in a big list, so that commands
  92.  * that search for a buffer by name can find the buffer header. There is a
  93.  * safe store for the dot and mark in the header, but this is only valid if
  94.  * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for
  95.  * the buffer is kept in a circularly linked list of lines, with a pointer to
  96.  * the header line in "b_linep".
  97.  */
  98. typedef struct  BUFFER {
  99.         struct  BUFFER *b_bufp;         /* Link to next BUFFER          */
  100.         struct  LINE *b_dotp;           /* Link to "." LINE structure   */
  101.         short   b_doto;                 /* Offset of "." in above LINE  */
  102.         struct  LINE *b_markp;          /* The same as the above two,   */
  103.         short   b_marko;                /* but for the "mark"           */
  104.         struct  LINE *b_linep;          /* Link to the header LINE      */
  105.         char    b_nwnd;                 /* Count of windows on buffer   */
  106.         char    b_flag;                 /* Flags                        */
  107.         char    b_fname[NFILEN];        /* File name                    */
  108.         char    b_bname[NBUFN];         /* Buffer name                  */
  109. }       BUFFER;
  110.  
  111. #define BFTEMP  0x01                    /* Internal temporary buffer    */
  112. #define BFCHG   0x02                    /* Changed since last write     */
  113.  
  114. /*
  115.  * The starting position of a region, and the size of the region in
  116.  * characters, is kept in a region structure.  Used by the region commands.
  117.  */
  118. typedef struct  {
  119.         struct  LINE *r_linep;          /* Origin LINE address.         */
  120.         short   r_offset;               /* Origin LINE offset.          */
  121.         short   r_size;                 /* Length in characters.        */
  122. }       REGION;
  123.  
  124. /*
  125.  * All text is kept in circularly linked lists of "LINE" structures. These
  126.  * begin at the header line (which is the blank line beyond the end of the
  127.  * buffer). This line is pointed to by the "BUFFER". Each line contains a the
  128.  * number of bytes in the line (the "used" size), the size of the text array,
  129.  * and the text. The end of line is not stored as a byte; it's implied. Future
  130.  * additions will include update hints, and a list of marks into the line.
  131.  */
  132. typedef struct  LINE {
  133.         struct  LINE *l_fp;             /* Link to the next line        */
  134.         struct  LINE *l_bp;             /* Link to the previous line    */
  135.         short   l_size;                 /* Allocated size               */
  136.         short   l_used;                 /* Used size                    */
  137.         char    l_text[1];              /* A bunch of characters.       */
  138. }       LINE;
  139.  
  140. #define lforw(lp)       ((lp)->l_fp)
  141. #define lback(lp)       ((lp)->l_bp)
  142. #define lgetc(lp, n)    ((lp)->l_text[(n)]&0xFF)
  143. #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
  144. #define llength(lp)     ((lp)->l_used)
  145.  
  146. /*
  147.  * The editor communicates with the display using a high level interface. A
  148.  * "TERM" structure holds useful variables, and indirect pointers to routines
  149.  * that do useful operations. The low level get and put routines are here too.
  150.  * This lets a terminal, in addition to having non standard commands, have
  151.  * funny get and put character code too. The calls might get changed to
  152.  * "termp->t_field" style in the future, to make it possible to run more than
  153.  * one terminal type.
  154.  */  
  155. typedef struct  {
  156.         short   t_nrow;                 /* Number of rows.              */
  157.         short   t_ncol;                 /* Number of columns.           */
  158.         int     (*t_open)();            /* Open terminal at the start.  */
  159.         int     (*t_close)();           /* Close terminal at end.       */
  160.         int     (*t_getchar)();         /* Get character from keyboard. */
  161.         int     (*t_putchar)();         /* Put character to display.    */
  162.         int     (*t_flush)();           /* Flush output buffers.        */
  163.         int     (*t_move)();            /* Move the cursor, origin 0.   */
  164.         int     (*t_eeol)();            /* Erase to end of line.        */
  165.         int     (*t_eeop)();            /* Erase to end of page.        */
  166.         int     (*t_beep)();            /* Beep.                        */
  167. }       TERM;
  168.  
  169. extern  int     fillcol;                /* Fill column                  */
  170. extern  int     currow;                 /* Cursor row                   */
  171. extern  int     curcol;                 /* Cursor column                */
  172. extern  int     thisflag;               /* Flags, this command          */
  173. extern  int     lastflag;               /* Flags, last command          */
  174. extern  int     curgoal;                /* Goal for C-P, C-N            */
  175. extern  int     mpresf;                 /* Stuff in message line        */
  176. extern  int     sgarbf;                 /* State of screen unknown      */
  177. extern  WINDOW  *curwp;                 /* Current window               */
  178. extern  BUFFER  *curbp;                 /* Current buffer               */
  179. extern  WINDOW  *wheadp;                /* Head of list of windows      */
  180. extern  BUFFER  *bheadp;                /* Head of list of buffers      */
  181. extern  BUFFER  *blistp;                /* Buffer for C-X C-B           */
  182. extern  short   kbdm[];                 /* Holds kayboard macro data    */
  183. extern  short   *kbdmip;                /* Input pointer for above      */
  184. extern  short   *kbdmop;                /* Output pointer for above     */
  185. extern  char    pat[];                  /* Search pattern               */
  186. extern  TERM    term;                   /*(Terminal information.        */
  187.  
  188. extern  BUFFER  *bfind();               /* Lookup a buffer by name      */
  189. extern  WINDOW  *wpopup();              /* Pop up window creation       */
  190. extern  LINE    *lalloc();              /* Allocate a line              */
  191.